/**
 * Performs the GET action from the href attribute of the given 'a' tag
 * @param a The 'a' tag
 * @returns {Boolean} False to prevent the page from loading
 */
function doAction(a) {
	$.ajax({
		url: a.getAttribute('href'),
		timeout: 2000, //in milliseconds
		success: function(data,textStatus,jqXHR) {
			try {
				var json = JSON.parse(data);
				var error = json['error'];
				$('#bottom_buttons > h3').text(typeof error != 'undefined' ? error : "");
			}
			catch(err) {  // when no json outputed, should never happen
				$('#bottom_buttons > h3').text("Something wrong happened");
			}
		},
		complete: function(jqXHR,textStatus) {
			doPoll(false); // update UI (may open an alert if user not connected)
		}
	});
	return false; // Prevent page from loading.
}

/**
 * Open a popup showing controls
 * @returns {Boolean} False to prevent the page from loading
 */
function openControls() {
	window.open('controls','controls','location=no,status=no,titlebar=no,toolbar=no,menubar=no,width=400,height=800').focus();
	return false; // Prevent page from loading.
}